# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=dapr-cli
pkgver=1.12.0
# API version described in https://docs.dapr.io/reference/api/
_runtimever=1.0
pkgrel=0
pkgdesc="CLI tool for Dapr the portable, event-driven runtime to build distributed applications"
url="https://dapr.io/"
# 32-bit: not useful
arch="all !x86 !armhf !armv7"
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/dapr/cli/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/cli-$pkgver"

build() {
	export CGO_ENABLED=0

	local _goldflags="
	-X main.version=$pkgver
	-X main.apiVersion=$_runtimever
	-X github.com/dapr/cli/pkg/standalone.gitversion=0000000
	-X github.com/dapr/cli/pkg/standalone.gitcommit=AlpineLinux
	"

	go build -v -ldflags "$_goldflags" -o dapr

	for shell in bash fish zsh; do
		./dapr completion $shell > dapr.$shell
	done
}

check() {
	# Avoid integration tests that require a local Docker or Kubernetes instance
	go test ./pkg/...
}

package() {
	install -Dm755 dapr -t "$pkgdir"/usr/bin/

	install -Dm644 dapr.bash \
		"$pkgdir"/usr/share/bash-completion/completions/dapr
	install -Dm644 dapr.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/dapr.fish
	install -Dm644 dapr.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_dapr
}

sha512sums="
766fe23d28172192a5308af13a72db9067a128a56c1658b48cd58c5cef6b458e37cbac4053798aec0fc416871da0f741c9e147aba0efb57292c86db5ad9ccd68  dapr-cli-1.12.0.tar.gz
"
